home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / xinetd / xinetd.2.0.6 / options.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-22  |  2.9 KB  |  132 lines

  1. /*
  2.  * (c) Copyright 1992 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. #include "options.h"
  8.  
  9. /*
  10.  * $Id: options.opt,v 5.2 1992/11/17 06:32:01 panos Exp $
  11.  */
  12.  
  13.  
  14. #define NULL         0
  15.  
  16. void exit() ;
  17.  
  18. int d_option ;
  19. int f_option ;
  20. char * f_option_arg_1 ;
  21. int filelog_option ;
  22. char * filelog_option_arg_1 ;
  23. int syslog_option ;
  24. char * syslog_option_arg_1 ;
  25. int reuse_option ;
  26. int limit_option ;
  27. unsigned limit_option_arg_1 ;
  28. int loop_option ;
  29. unsigned loop_option_arg_1 ;
  30. int pid_option ;
  31. int logprocs_option ;
  32. unsigned logprocs_option_arg_1 ;
  33. int shutdownprocs_option ;
  34. unsigned shutdownprocs_option_arg_1 ;
  35.  
  36. char *program_name ;
  37.  
  38. int opt_recognize( argc, argv )
  39.     int argc ;
  40.     char *argv[] ;
  41. {
  42.     int arg ;
  43.     char *strrchr() ;
  44.  
  45.     program_name = strrchr( argv[ 0 ], '/' ) ;
  46.     program_name = ( program_name == NULL ) ? argv[ 0 ] : program_name + 1 ;
  47.  
  48.     for ( arg = 1 ; arg < argc ; arg++ )
  49.         if ( argv[ arg ][ 0 ] == '-' )
  50.         {
  51.             if ( strcmp( &argv[ arg ][ 1 ], "d" ) == 0 ) 
  52.                 d_option = 1 ;
  53.             else if ( strcmp( &argv[ arg ][ 1 ], "f" ) == 0 ) 
  54.             {
  55.                 if ( ++arg == argc )
  56.                     usage() ;
  57.                 f_option_arg_1 = ( argv[ arg ] ) ;
  58.                 f_option = 1 ;
  59.             }
  60.             else if ( strcmp( &argv[ arg ][ 1 ], "filelog" ) == 0 ) 
  61.             {
  62.                 if ( ++arg == argc )
  63.                     usage() ;
  64.                 filelog_option_arg_1 = ( argv[ arg ] ) ;
  65.                 filelog_option = 1 ;
  66.             }
  67.             else if ( strcmp( &argv[ arg ][ 1 ], "syslog" ) == 0 ) 
  68.             {
  69.                 if ( ++arg == argc )
  70.                     usage() ;
  71.                 syslog_option_arg_1 = ( argv[ arg ] ) ;
  72.                 syslog_option = 1 ;
  73.             }
  74.             else if ( strcmp( &argv[ arg ][ 1 ], "reuse" ) == 0 ) 
  75.                 reuse_option = 1 ;
  76.             else if ( strcmp( &argv[ arg ][ 1 ], "limit" ) == 0 ) 
  77.             {
  78.                 int atoi() ;
  79.  
  80.                 if ( ++arg == argc )
  81.                     usage() ;
  82.                 limit_option_arg_1 = atoi( argv[ arg ] ) ;
  83.                 limit_option = 1 ;
  84.             }
  85.             else if ( strcmp( &argv[ arg ][ 1 ], "loop" ) == 0 ) 
  86.             {
  87.                 int atoi() ;
  88.  
  89.                 if ( ++arg == argc )
  90.                     usage() ;
  91.                 loop_option_arg_1 = atoi( argv[ arg ] ) ;
  92.                 loop_option = 1 ;
  93.             }
  94.             else if ( strcmp( &argv[ arg ][ 1 ], "pid" ) == 0 ) 
  95.                 pid_option = 1 ;
  96.             else if ( strcmp( &argv[ arg ][ 1 ], "logprocs" ) == 0 ) 
  97.             {
  98.                 int atoi() ;
  99.  
  100.                 if ( ++arg == argc )
  101.                     usage() ;
  102.                 logprocs_option_arg_1 = atoi( argv[ arg ] ) ;
  103.                 logprocs_option = 1 ;
  104.             }
  105.             else if ( strcmp( &argv[ arg ][ 1 ], "shutdownprocs" ) == 0 ) 
  106.             {
  107.                 int atoi() ;
  108.  
  109.                 if ( ++arg == argc )
  110.                     usage() ;
  111.                 shutdownprocs_option_arg_1 = atoi( argv[ arg ] ) ;
  112.                 shutdownprocs_option = 1 ;
  113.             }
  114.         }
  115.         else
  116.             break ;
  117.  
  118.     if ( filelog_option + syslog_option > 1 )
  119.         usage() ;
  120.  
  121.  
  122.     if ( argc - arg != 0 )
  123.         usage() ;
  124.     return( arg ) ;
  125. }
  126.  
  127. void usage()
  128. {
  129.     Sprint( 2, "Usage: %s [-d] [-f config_file] [-filelog filename] [-syslog facility] [-reuse] [-limit proc_limit] [-loop loop_rate] [-pid] [-logprocs limit] [-shutdownprocs limit]\n", program_name ) ;
  130.     exit( 1 ) ;
  131. }
  132.